package chamster.actions;

import java.awt.Point;

import chamster.BaseHamster;
public class GoFrontRightAction<HamsterType extends BaseHamster> 
	extends CompoundAction<HamsterType> {

	public boolean isApplicable(HamsterType hamster) throws Exception {
		return hamster.getView().canMoveTo(new Point(1, 1),  2) 
				&& hamster.chargeLeft(3);
	}

	public void run(HamsterType hamster) throws Exception {
		if(hamster.canMoveForeward()) {
			hamster.foreward();
			super.pickup(hamster);
			hamster.turnRight();
			hamster.foreward();
			hamster.turnLeft();
		}
		else {
			hamster.turnRight();
			hamster.foreward();
			super.pickup(hamster);
			hamster.turnLeft();
			hamster.foreward();
		}
	}

}
